package com.zhima.dto;

import com.zhima.exception.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ZhimaOjResult extends BaseResultDTO {
    private Object source;

    private ZhimaOjResult(String errorMessage, boolean success, Object source) {
        super(errorMessage, success);
        this.source = source;
    }

    public static ZhimaOjResult success(Object source) {
        return new ZhimaOjResult(null, true, source);
    }

    public static ZhimaOjResult success() {
        return new ZhimaOjResult(null, true, null );
    }

    public static ZhimaOjResult fail() {
        return new ZhimaOjResult(null, false, null );
    }

    public static ZhimaOjResult fail(String errorMessage) {
        return new ZhimaOjResult(errorMessage, false, null);
    }

    public static ZhimaOjResult fail(ErrorCode errorCode) {
        return new ZhimaOjResult(errorCode.getErrorMessage(), false, null );
    }
}
